layui.use(['form','layer'],function () {
    $ = layui.jquery;
    var form = layui.form,
        layer = layui.layer;


    form.verify({

        newPwd: function (value) {
            if (value.length < 6) {
                return "密码长度不能小于6位";
            }
        },
        confirmPwd: function (value) {
            if ($("#newPwd").val() !== value) {
                return "两次输入密码不一致，请重新输入！";
            }
        }
    });


    form.on('submit(changePwd)', function (data) {

        $.ajax({
            url:'/sharepark/user/resetPassword',
            type: 'post',
            dataType: 'json',
            data: {
                'oldPass': $("#oldPwd").val(),
                'newPass': $("#newPwd").val()
            },
            success: function (res) {
                layer.msg(res.msg);
                if (res.msg==='重置密码成功') {

                    parent.location.replace("/sharepark/login.html");
                }else {
                 location.reload();
                }
            }


        });
        return false;
    })

})
